<template>
  <div>
    <el-dialog title="详细信息" :visible.sync="dialogVisible" class="dialog">
      <el-descriptions direction="vertical" :column="2" border>
        <el-descriptions-item label="充值单号">{{
          info.orderNo
        }}</el-descriptions-item>
        <el-descriptions-item label="充值凭证">
          <el-image v-for="(item, index) in info.imgs" :key="index" style="width: 100px; height: 100px" :src="item"
            :preview-src-list="info.imgs">
          </el-image>
        </el-descriptions-item>
        <el-descriptions-item label="充值金额">{{
          info.amount
        }}
          <span style="margin-left: 8px;">{{ info.type == 'rmb' ? 'rmb' : 'usdt' }}</span></el-descriptions-item>
        <el-descriptions-item label="充值类型">
          {{ info.type == 'rmb' ? 'rmb' : 'usdt' }}
        </el-descriptions-item>
        <el-descriptions-item label="充值时间">{{
          info.createTime
        }}</el-descriptions-item>

        <el-descriptions-item label="用户id">{{
          info.userId
        }}</el-descriptions-item>
        <el-descriptions-item v-if="info.status == 'applying'" label="审核">
          <el-select v-model="vo.status" placeholder="请选择">
            <el-option label="审核通过" value="approved" />
            <el-option label="审核驳回" value="reject" />
          </el-select>
        </el-descriptions-item>
        <el-descriptions-item v-if="info.status != 'applying'" label="审核">
          {{ setStateTxt(info.status) }}
        </el-descriptions-item>

      </el-descriptions>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="videoStatae" title="视频">
      <video :src="video" controls style="width: 100%; height: 300px" />
    </el-dialog>
  </div>
</template>
<script>
import { _isMobile } from '@/utils/index'
import { rechargeApproval } from '@/api/table'
export default {
  data() {
    return {
      dialogVisible: false,
      info: {},
      isMobile: _isMobile,
      imageList: [],
      videoList: [],
      video: null,
      videoStatae: false,
      vo: {
        'id': '',
        'status': ''
      }
    }
  },

  methods: {
    setStateTxt(index) {
      let str = ''
      switch (index) {
        case 'applying':
          str = '申请中'
          break
        case 'approved':
          str = '审核通过'
          break
        case 'reject':
          str = '审核驳回'
          break
      }
      return str
    },
    show(e) {
      this.dialogVisible = true
      this.info = e
      if (this.info.evidence) {
        this.info.imgs = JSON.parse(this.info.evidence)
      }
    },
    async confirm() {
      if (this.vo.status) {
        this.vo.id = this.info.id
        await rechargeApproval(this.vo)
        this.$parent.fetchData()
        this.dialogVisible = false
      } else {
        this.dialogVisible = false
      }
    }
  }
}
</script>
